<?php
/**
 * Created by PhpStorm.
 * User: zhongyb
 * Date: 2016/6/6
 * Time: 21:12
 */
namespace common\repositories\common;

use common\repositories\BaseRepository;
use common\entities\common\PigcmsUsersEntity;
use Yii;

class PigcmsUsersRepository extends BaseRepository {


    public function deleteByOrganizationId($organizationId)
    {
        return PigcmsUsersEntity::deleteAll([
            'OrganizationId' => $organizationId
        ]);
    }

    /**
     * 根据用户名称修改密码
     * @param $pwd
     * @param $userName
     * @return bool
     */
    public function updateByUserName($pwd, $userName)
    {
        $entity = PigcmsUsersEntity::find()
            ->where(['username'=>$userName])
            ->one();
        if($entity){
            $entity->password = $pwd;
            $entity->save();
            return true;
        }
        return false;
    }

}